//
//  MyView.m
//  CloseLightGame
//
//  Created by dllo on 15/4/22.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MyView.h"

@implementation MyView
- (void)dealloc
{
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createButton];
    }
    return self;
}

- (void)createButton
{
    for (int i = 0; i < 25; i ++) {
        UIButton *aButton = [[UIButton alloc] initWithFrame:CGRectMake(i % 5 * 60 + 40, i / 5 * 60 + 100, 50, 50)];
        aButton.tag = i + 1;
        aButton.backgroundColor = [UIColor orangeColor];
        [aButton setTitle:@"light" forState:UIControlStateNormal];
        [aButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [aButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:aButton];
        [aButton release];
    }
}
- (void)buttonAction:(id)sender
{
    [(NSObject *)self.target performSelector:self.action withObject:sender];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
